package org.lcx.pipeline.example;

import java.text.MessageFormat;
import java.util.Map;
import java.util.Random;

import org.lcx.pipeline.Processor;
import org.lcx.pipeline.bean.PipelineExeption;
import org.lcx.pipeline.bean.PipelineResult;
import org.springframework.beans.factory.annotation.Autowired;

/**
 * 下班
 */
public class TimeoffProcessor implements Processor {


	@Override
	public int runProcess(Object params, PipelineResult result) throws PipelineExeption {
		@SuppressWarnings("unchecked")
		Map<String, Object> inParam = (Map<String, Object>) params;

		Random random = new Random();
		int randomNum = random.nextInt(10);
		String msgFormat = "hi,{0}下班啦,今天选择做什么交通工具回家呢？摇一下骰子吧,骰子是{1}";
		System.out.println(MessageFormat.format(msgFormat, inParam.get("name"), randomNum));

		if (randomNum >= 5) {
			return 2;
		}
		return 1;
	}

}
